package com.manage.user.provider;

import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.manage.utils.Criteria;

/**
 * @author Fitch
 */
public class UserProvider {

    public String listUser(Criteria criteria){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT id,user_name as userName ," +
                "`password`,is_valid as isValid," +
                "create_user as createUser,create_time as createTime " +
                "FROM `user` where 1=1;");
        this.getWhereSql(criteria);
        return sql.toString();
    }

    private String getWhereSql(Criteria criteria) {
        StringBuilder sql = new StringBuilder("");
        if (StringUtils.isNotEmpty(criteria.getString("userName"))) {
            sql.append(" and user_name =#{condition.userName}");
        }
        return sql.toString();
    }
}
